// 2025/3/2
// https://leetcode.cn/problems/group-anagrams/description/?envType=study-plan-v2&envId=top-100-liked
// 字母异位词分组

class Solution {
    public:
        vector<vector<string>> groupAnagrams(vector<string>& strs) {
            unordered_map<string, vector<string>> ret;
            for (auto& e : strs)
            {
                string key(26, 0);
                for (auto& ch : e) 
                    ++key[ch - 'a'];
                ret[key].emplace_back(e);
            }
            vector<vector<string>> ans;
            for (auto& e : ret) ans.emplace_back(e.second);
            return ans;
        }
    };